import {CHANGE_LAYOUT_COLLAPSED, SAVE_CLEARED_NOTICES, SAVE_NOTICES} from "./const";

const initState = {
  collapsed: false,
  notices: [],
};

export default function reucer(state = initState, {type, payload}) {
  switch (type) {
    case CHANGE_LAYOUT_COLLAPSED:
      return {
        ...state,
        collapsed: payload,
      };
    case SAVE_NOTICES:
      return {
        ...state,
        notices: payload,
      };
    case SAVE_CLEARED_NOTICES:
      return {
        ...state,
        notices: state.notices.filter(item => item.type !== payload),
      };
    default:
      return state;
  }
}
